$(function() {
    $('.republic-box').hide().eq(0).show();
    $(function() {

        $('.summernote').summernote({
            height: 300,
            tabsize: 2,
            lang: 'zh-CN'
        });
    });
    var $step = $("#step");
    var $index = $("#index");

    $step.step({
        index: 0,
        time: 500,
        title: ["基本信息", "商品参数", "商品属性", "商品图片", "完成"]
    });

    $index.text($step.getIndex());

    $("#prevBtn").on("click", function() {

        $step.prevStep();
        $index.text($step.getIndex());
        let mum = $('#index').text()
        $('.republic-box').stop().hide().eq(mum).fadeIn(800);
    });

    $("#nextBtn").on("click", function() {

        $step.nextStep();
        $index.text($step.getIndex());
        let mum = $('#index').text()
        $('.republic-box').stop().hide().eq(mum).fadeIn(800);
    });

    $("#btn1").on("click", function() {

        $step.toStep(1);
        $index.text($step.getIndex());
        let mum = $('#index').text()
        $('.republic-box').stop().hide().eq(mum).fadeIn(800);
    });

    $("#btn2").on("click", function() {

        $step.toStep(2);
        $index.text($step.getIndex());
        let mum = $('#index').text()
        $('.republic-box').stop().hide().eq(mum).fadeIn(800);
    });
    $('.republic-box').hide().eq(0).show();
    let mmm = 2

    $('.myaddshuxin').click(function() {
        mmm++;
        // alert(mmm)
        let moban = `<div class="input-group mb-2 mr-sm-2  addshuxin">
            <div class="input-group-text">#<span>${mmm}</span></div>
            <input type="text" class="form-control" id="inlineFormInputGroupUsername2" placeholder="参数名">
            <input type="text" class="form-control mb-2 mr-sm-2" id="inlineFormInputName2" placeholder="参数值">
        </div>`
        $('#box2').append(moban)
    })
    $('.myremoveshuxin').click(function() {
        if ($('.addshuxin').length == 1) {
            alert('至少需要添加一个参数！');
            return
        }
        mmm--
        $('.addshuxin:last-child').remove()
    })
    let nnn = 6
    $('.addimg').click(function() {
        if (nnn == 8) {
            alert('最多添加8张图片！');
            return
        }
        nnn++
        let imgmb = `<label for="exampleFormControlInput${nnn}6" class=" img-label"><br></label>
            <input type="file" name="" id="exampleFormControlInput${nnn}6">`
        $('#imgbox').append(imgmb)
    })
    $('.removeimg').click(function() {
            if (nnn == 0) {
                alert('至少需要添加一张图片！');
                return
            }
            nnn--;
            $('#imgbox label:last-child').remove()
            $('#imgbox input:last-child').remove()
        })
        /*************************************************** */
})